//
//  InfoPanel.m
//  AsyncImages
//
//  Created by Matthew on 12-3-28.
//  Copyright 2012年 develop4u.gr. All rights reserved.
//

#import "InfoPanel.h"
#import "UIImageLayer.h"

@implementation InfoPanel

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        UIImageLayer *bg = [[UIImageLayer alloc] initWithFrame:CGRectMake(0, 0, 120, 120)];
        [bg initImage:@"info_bg.png" useOriginalSize:TRUE ratioMode:TRUE layerInfo:Nil];
        [self addSubview:bg];
        
        activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        activityIndicator.frame = CGRectMake(40, 40, 40.0, 40.0);
        [activityIndicator startAnimating];
        [self addSubview:activityIndicator];
        
        titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 30, 80, 80)];
        titleLabel.font = [UIFont fontWithName:@"STHeitiSC-Medium" size:16.0];
        [titleLabel setBackgroundColor:[UIColor clearColor]];
        [titleLabel setTextColor:[UIColor whiteColor]];
        titleLabel.textAlignment = UITextAlignmentCenter;
        [titleLabel setText:@"登陆成功"];
        [self addSubview:titleLabel];
        titleLabel.hidden = TRUE;
    }
    return self;
}

-(void) startLogin
{
    self.alpha = 1.0f; 
    activityIndicator.hidden = false;
    titleLabel.hidden = true;
}

-(void) loginSuccess
{
    activityIndicator.hidden = true;
    titleLabel.hidden = false;

    [UIView animateWithDuration:1.0f 
                          delay:1.0f 
                        options:UIViewAnimationCurveEaseOut 
                     animations:^{
                         self.alpha = 0.0f; 
                     }
                     completion:NULL];
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

- (void)dealloc
{
    [super dealloc];
}

@end
